package com.wunong.smart.address.service;

import com.wunong.smart.address.client.param.UserAddressParam;
import com.wunong.smart.address.client.param.DeleteUserAddressParam;
import com.wunong.smart.address.client.param.SetDefaultUserAddressParam;
import com.wunong.smart.address.client.service.UserAddressWriteService;
import com.wunong.smart.address.application.request.DeleteUserAddressRequest;
import com.wunong.smart.address.application.request.SetDefaultUserAddressRequest;
import com.wunong.smart.address.application.request.UpdateUserAddressRequest;
import com.wunong.smart.address.domain.service.UserAddressDomainService;
import com.wunong.smart.domain.platform.rpc.Result;

import javax.annotation.Resource;

/**
 * @author create by zealot.zt
 */
public class UserAddressWriteServiceImpl implements UserAddressWriteService {

    @Resource
    private UserAddressDomainService userAddressDomainService;

    @Override
    public Result<Long> save(UserAddressParam param) {
        return Result.create(userAddressDomainService.save(UpdateUserAddressRequest.of(param)));
    }

    @Override
    public Result<Void> update(UserAddressParam param) {
        return Result.create(userAddressDomainService.update(UpdateUserAddressRequest.of(param)));
    }

    @Override
    public Result<Void> delete(DeleteUserAddressParam param) {
        return Result.create(userAddressDomainService.delete(DeleteUserAddressRequest.of(param)));
    }

    @Override
    public Result<Void> setDefault(SetDefaultUserAddressParam param) {
        return Result.create(userAddressDomainService.setDefault(SetDefaultUserAddressRequest.of(param)));
    }

}
